package com.orion.schdule;

import com.orion.util.SmallTool;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * spring的schedule线程池默认只有一个线程
 *
 * 单个指定时间执行的定时任务
 *
 * @author Administrator
 */
@Component
@ConditionalOnProperty(value = "schedule.singleFixDateScheduleTask",havingValue = "true")
public class SingleFixDateScheduleTask {

    @Scheduled(cron = "0,2 * * * * ? ")
    public void JustScheduleForA() {
        SmallTool.printTimeAndThread("begin Just Schedule Task A ");
/*

        SmallTool.sleepMillis(4000);
        SmallTool.printTimeAndThread("end Just Schedule Task A ");
*/

    }
    /**
     * 如果任务执行时间越过下次的定时时间，那么就丢失了这任务，否则不会消失
     *
     1644734400003	|	30	|	scheduling-1	|	begin Just Schedule Task A
     1644734404013	|	30	|	scheduling-1	|	end Just Schedule Task A
     1644734460007	|	30	|	scheduling-1	|	begin Just Schedule Task A
     1644734464013	|	30	|	scheduling-1	|	end Just Schedule Task A
     1644734520015	|	30	|	scheduling-1	|	begin Just Schedule Task A
     1644734524025	|	30	|	scheduling-1	|	end Just Schedule Task A


     没有超过下次指定时间
     1644734700006	|	30	|	scheduling-1	|	begin Just Schedule Task A
     1644734702011	|	30	|	scheduling-1	|	begin Just Schedule Task A
     1644734760003	|	30	|	scheduling-1	|	begin Just Schedule Task A
     1644734762003	|	30	|	scheduling-1	|	begin Just Schedule Task A
     */
}
